package org.jeecg.modules.util;

import com.alibaba.fastjson.JSON;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;


public class Http {
    public static void main(String[] args) throws Exception{
//        String code = "123456";
        HttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost("https://api.4321.sh/sms/template");
//        HttpPost httpPost = new HttpPost("https://api.4321.sh/sms/send");
        httpPost.addHeader("Content-Type","application/json");
        Map<String,Object> map = new HashMap<>();
        map.put("apikey","N1330799b69");
        map.put("secret","13307943024bf6eda");
        map.put("sign_id",232175);
        map.put("mobile","15900675459");
        map.put("template_id",223161);
        map.put("content", "验证码为：123321");
        String json = JSON.toJSONString(map);
        System.out.println("请求参数===" + json);
        httpPost.setEntity(new StringEntity(json,"UTF-8"));

        HttpResponse response = httpClient.execute(httpPost);
        HttpEntity entity = response.getEntity();
        String res = EntityUtils.toString(entity);
        System.out.println(res);
    }
}